<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\order;

use app\common\controller\Order;
use app\controller\admin\AuthController;
use app\Request;
use think\facade\Db;
use app\services\order\{
    StoreOrderServices
};
use think\facade\App;

/**
 * 订单管理
 * Class StoreOrder
 * @package app\controller\admin\v1\order
 */
class StoreOrder extends AuthController
{

    use Order;

    /**
     * StoreOrder constructor.
     * @param App $app
     * @param StoreOrderServices $service
     */
    public function __construct(App $app, StoreOrderServices $service)
    {
        parent::__construct($app);
        $this->services = $service;
    }

	/**
	 * 易联云打印机打印
	 * @param $id
	 * @return mixed
	 */
	public function order_print($id)
	{
		if (!$id) return app('json')->fail('缺少参数');
		$order = $this->services->get($id);
		if (!$order) {
			return app('json')->fail('订单没有查到,无法打印!');
		}
		$res = $this->services->orderPrint((int)$id, 0, 0);
		if ($res) {
			return app('json')->success('打印成功');
		} else {
			return app('json')->fail('打印失败');
		}
	}
    public function designated_personnel_return(Request $request)
    {
        [$id,$delivery_uid] = $request->postMore([
            ['id',''],
            ['delivery_uid','']
        ], true);

        Db::name('store_order')->where('order_id',$id)->update(['delivery_uid'=>$delivery_uid]);

        return app('json')->successful('操作成功');
    }

}
